package lily.phs.healthedu;



import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ExpandableListView;
import android.widget.ExpandableListView.OnChildClickListener;
import android.widget.Button;
import android.widget.GridView;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import android.widget.Toast;
import lily.phs.urh.R;

public class HealthTrainActivity extends Activity {
	private ExpandableListView elv;	
	private Button bt,rightBtn,rightBtn2;//新加	
	private TextView tv;//新加
	private MyExpandableListAdapter mAdapter;
	private SimpleAdapter gvAdapter;	
	private static int currentGroup;
	private static int currentChild;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);        
        requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);//新加
        setContentView(R.layout.health_training);//新加	
        getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.i_title);//新加
		
        tv=(TextView) findViewById(R.id.title);
        tv.setText("健康培训");
        bt=(Button) findViewById(R.id.title_left_btn);
        rightBtn = (Button) findViewById(R.id.title_right_btn);
        rightBtn2 = (Button) findViewById(R.id.title_right_btn2);
        rightBtn.setVisibility(View.GONE);
        rightBtn2.setVisibility(View.GONE);
        bt.setText("后退");
        bt.setOnClickListener(new Button.OnClickListener()
        {

        	@Override
        	public void onClick(View v) {
        		finish();
        		overridePendingTransition(R.anim.anim_slide_in_left,R.anim.anim_slide_out_right);
        	}
			
        });
      
        String[] groupItems = HealthTrainActivity.this.getResources().getStringArray(R.array.trainning_array_group);
        int[] groupIcons = new int[]{R.drawable.trainning_shiyijishu,R.drawable.trainning_jizhenjijiu,R.drawable.trainning_heliyongyao,R.drawable.trainning_kaoqianfudao,R.drawable.trainning_shebeishiyong,R.drawable.trainning_mingyikecheng};
        String[][] childrenItems = new String[][]{
        		HealthTrainActivity.this.getResources().getStringArray(R.array.trainning_array_group1),
        		HealthTrainActivity.this.getResources().getStringArray(R.array.trainning_array_group2),
        		HealthTrainActivity.this.getResources().getStringArray(R.array.trainning_array_group3),
        		HealthTrainActivity.this.getResources().getStringArray(R.array.trainning_array_group4),
        		HealthTrainActivity.this.getResources().getStringArray(R.array.trainning_array_group5),
        		{},
        };
        
        mAdapter = new MyExpandableListAdapter(HealthTrainActivity.this,groupItems,groupIcons,childrenItems,null);
		elv = (ExpandableListView) this.findViewById(R.id.elv_main);
		elv.setDivider(null);
		elv.setAdapter(mAdapter);
	
		elv.setOnChildClickListener(new OnChildClickListener(){

			@Override
			public boolean onChildClick(ExpandableListView parent, View v,
					int groupPosition, int childPosition, long id) {
				// TODO Auto-generated method stub
				
//				elv.setAnimation(out_left);
//				elv.startAnimation(out_left);
//				elv.setVisibility(View.GONE);
//				lv.setAnimation(in_right);
//				lv.startAnimation(in_right);
//				lv.setVisibility(View.VISIBLE);
				
				currentGroup = groupPosition;
				currentChild = childPosition;
				
				if(groupPosition==0){
					Intent intent = new Intent(HealthTrainActivity.this,shiyijishu.class);
					Bundle bundle = new Bundle();
					bundle.putInt("group", currentGroup);
					bundle.putInt("child", currentChild);
					intent.putExtras(bundle);
					startActivity(intent);
					overridePendingTransition(R.anim.anim_slide_in_right,R.anim.anim_slide_out_left);
					//finish();
				}
				else if(groupPosition==1){
					Intent intent = new Intent(HealthTrainActivity.this,jizhenjijiu.class);
					Bundle bundle = new Bundle();
					bundle.putInt("group", currentGroup);
					bundle.putInt("child", currentChild);
					intent.putExtras(bundle);
					startActivity(intent);
					overridePendingTransition(R.anim.anim_slide_in_right,R.anim.anim_slide_out_left);
					//finish();
				}
				else if(groupPosition==2){
					Intent intent = new Intent(HealthTrainActivity.this,heliyongyao.class);
					Bundle bundle = new Bundle();
					bundle.putInt("group", currentGroup);
					bundle.putInt("child", currentChild);
					intent.putExtras(bundle);
					startActivity(intent);
					overridePendingTransition(R.anim.anim_slide_in_right,R.anim.anim_slide_out_left);
					//finish();
				}
				else if(groupPosition==3){
					Intent intent = new Intent(HealthTrainActivity.this,kaoqianfudao.class);
					Bundle bundle = new Bundle();
					bundle.putInt("group", currentGroup);
					bundle.putInt("child", currentChild);
					intent.putExtras(bundle);
					startActivity(intent);
					overridePendingTransition(R.anim.anim_slide_in_right,R.anim.anim_slide_out_left);
					//finish();
				}
				else if(groupPosition==4){
					Intent intent = new Intent(HealthTrainActivity.this,shebeishiyong.class);
					Bundle bundle = new Bundle();
					bundle.putInt("group", currentGroup);
					bundle.putInt("child", currentChild);
					intent.putExtras(bundle);
					startActivity(intent);
					overridePendingTransition(R.anim.anim_slide_in_right,R.anim.anim_slide_out_left);
					//finish();					
				}
				/*
				
				else{
					Toast.makeText(TrainningMainActivity.this, "开发中……", Toast.LENGTH_LONG).show();
				}*/
				
				return true;
			}
			
		});
		
		/*gv.setOnItemClickListener(new OnItemClickListener(){

			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int which, long arg3) {
				// TODO Auto-generated method stub
				switch(which){
				case 0:{//主界面
					startActivity(new Intent(TrainningMainActivity.this,MainActivity.class));
					overridePendingTransition(R.anim.anim_slide_in_left,R.anim.anim_slide_out_right);
					finish();
					break;
				}
				case 1:{//back
					finish();
					overridePendingTransition(R.anim.anim_slide_in_left,R.anim.anim_slide_out_right);
					break;
				}
				case 2:{//
					
					break;
				}
				}
			}
			
		});*/
		
		
		
		
        
        
    }
    
    @Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		// TODO Auto-generated method stub
		//finish();
		return super.onKeyDown(keyCode, event);
	}
    
    
    
   
}
